import Cookie from 'js-cookie' ;


function getServerCookies (req) {
  let ck = {} ;
  req && req.headers.cookie && req.headers.cookie.split(';').forEach((val) => {
    let parts = val.split('=');
    ck[parts[0].trim()] = (parts[1] || '').trim() ;
  })

  return ck ;
}

function getClientCookies(key) {
  return Cookie.get(key) ? Cookie.get(key) : '' ;
}

export {
  getServerCookies,
  getClientCookies,
}
